import urllib.request
import urllib.parse
from http import cookiejar

headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36",
}

url = "http://www.renren.com/541197383/profile"


filename = 'renrencookie.txt'
cookies = cookiejar.LWPCookieJar()
cookies.load(filename=filename,ignore_discard=True)
cookie_jar = urllib.request.HTTPCookieProcessor(cookies)
opener = urllib.request.build_opener(cookie_jar)
urllib.request.install_opener(opener) #创建全局打开器



req = urllib.request.Request(url,headers=headers)
response = urllib.request.urlopen(req)
print(response.read().decode())
